package com.globallogic.capacitaciones.hibernate.mo;

import java.math.BigDecimal;
import java.util.Date;

import org.springframework.stereotype.Component;

import com.cubika.devsupport.motherobject.DatabaseProviderMotherObjectImpl;
import com.cubika.devsupport.motherobject.TestObject;
import com.globallogic.capacitaciones.hibernate.domain.Item;

@Component
public class ItemMO extends DatabaseProviderMotherObjectImpl<Item>{

	
	
	public ItemMO() {
		super(Item.class);
	}

	@Override
	public Item getDefault() {
		return getSampleItem();
	}
	
	@TestObject
	public Item getSampleItem(){
		if(!instanceExists("sampleItem")){
			Date now = new Date();
			Item item = new Item();
			item.setName("Sample Name");
			item.setDescription("Sample Description");
			item.setInitialPrice(BigDecimal.valueOf(10));
			item.setReservePrice(BigDecimal.valueOf(10));
			item.setApprovalDatetime(now);
			item.setEndDate(now);
			item.setStartDate(now);
			addInstance("sampleItem", item);
		}
		return getInstance("sampleItem");
	}
	

}
